#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include <QMediaPlaylist>
#include "musiclist.h"

namespace Ui {
class CommonPage;
}

enum PageType
{
    LIKE_PAGE,      //我喜欢页面
    LOCAL_PAGE,     //本地音乐页面
    HISTORY_PAGE    //历史播放页面
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

    void setMusicListType(PageType musicListType);

    void setCommonPageUi(const QString &imagePath, const QString &text);

    void addMuiscToPage(MusicList &musicList);

    void addMusicToPlaylist(MusicList &musicList, QMediaPlaylist *playlist);

    QString getMusicIdByIndex(int index);

    void reFresh(MusicList &musicList);

signals:
    void updateLikeMusic(bool isLike, const QString& musicId);

    void playAll(PageType pageType);

    void playMusicByIndex(CommonPage *page, int index);
private:
    Ui::CommonPage *ui;
    PageType pageType;
    QVector<QString> musicOfPage;   //保存页面对应歌曲的ID
};

#endif // COMMONPAGE_H
